/*
 * This file is part of WebCL – JavaScript bindings for OpenCL
 * http://webcl.nokiaresearch.com/
 *
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 *
 * Contact: Jari Nikara  ;jari.nikara@nokia.com;
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 *
 * The package is based on a published Khronos OpenCL 1.1 Specification,
 * see http://www.khronos.org/opencl/.
 *
 * OpenCL is a trademark of Apple Inc.
 */

#include "WebCLObserver.h"

#include "WebCL.h"
#include "WebCLLogger.h"

#include <nsIVariant.h>
#include <nsIObserver.h>

NS_IMPL_ISUPPORTS1(WebCLObserver, nsIObserver)


WebCLObserver::WebCLObserver ()
  : nsIObserver(), mWebCL(0)
{
  D_METHOD_START;
}

WebCLObserver::~WebCLObserver ()
{
  D_METHOD_START;
}

void WebCLObserver::setWebCL (WebCL* aWebCL)
{
  mWebCL = aWebCL;
}

NS_IMETHODIMP WebCLObserver::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
{
  D_LOG (LOG_LEVEL_DEBUG, "topic=%s%s", aTopic, mWebCL?"":"  WEBCL NOT SET!");

  return (mWebCL ? (mWebCL->preferenceChanged (aSubject, aTopic, aData)) : NS_ERROR_FAILURE);
}

